import cv2 as cv
import numpy as np
# 颜色分割
def In1():
    img = cv.imread('./img/bird.png')
    # 滤波
    blur = cv.blur(img, (5, 5))
    blur0 = cv.medianBlur(blur, 5)
    blur1 = cv.GaussianBlur(blur0,(5,5),0)
    blur2 = cv.bilateralFilter(blur1,9,75,75)

    # BGR -> 亮度,饱和度,色度
    hsv = cv.cvtColor(blur2, cv.COLOR_BGR2HSV)
    # 颜色分割
    low_blue = np.array([55,0,0])
    high_blue = np.array([118,255,255])
    mask = cv.inRange(hsv,low_blue,high_blue)
    # 以mask作为边界生成结果图像
    res = cv.bitwise_and(img,img,mask=mask)
    cv.imshow('bird', res)
    cv.waitKey(0) # 程序等待，直到有按键事件才执行后续
    cv.destroyAllWindows()   
# In1()

# 图片覆盖
def In2():
    img1 = cv.imread('./img/cat.png')

    img2 = cv.imread('./img/bird.png')
    resized_img2 = cv.resize(img2, dsize=(100,100))

    img1[50:150,50:150] = resized_img2

    # 读取png图片带alpha通道
    # img3 = cv.imread('./img/cat.png', cv.IMREAD_UNCHANGED)
    # print(img3)

    cv.imshow('cat', img1)
    cv.waitKey(0) # 程序等待，直到有按键事件才执行后续
    cv.destroyAllWindows()
# In2()

# 全景图片拼接
def In3():
    pass

# 人脸识别